{
 "nbformat": 4,
 "nbformat_minor": 2,
 "metadata": {
  "language_info": {
   "name": "python",
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "version": "3.7.7-final"
  },
  "orig_nbformat": 2,
  "file_extension": ".py",
  "mimetype": "text/x-python",
  "name": "python",
  "npconvert_exporter": "python",
  "pygments_lexer": "ipython3",
  "version": 3,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3"
  }
 },
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "dl={\n",
    "    \"城市\":['北京','上海','广州','深圳','沈阳'],\n",
    "    '环比':[101.5,101.2,101.3,102.0,100.1],\n",
    "    '同比':[120.7,127.3,119.4,140.9,101.4],\n",
    "    '定基':[121.4,127.8,120.0,145.5,101.6]\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "d=pd.DataFrame(dl,index=['c1','c2','c3','c4','c5'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "    城市     环比     同比     定基\nc1  北京  101.5  120.7  121.4\nc2  上海  101.2  127.3  127.8\nc3  广州  101.3  119.4  120.0\nc4  深圳  102.0  140.9  145.5\nc5  沈阳  100.1  101.4  101.6",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>城市</th>\n      <th>环比</th>\n      <th>同比</th>\n      <th>定基</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>c1</th>\n      <td>北京</td>\n      <td>101.5</td>\n      <td>120.7</td>\n      <td>121.4</td>\n    </tr>\n    <tr>\n      <th>c2</th>\n      <td>上海</td>\n      <td>101.2</td>\n      <td>127.3</td>\n      <td>127.8</td>\n    </tr>\n    <tr>\n      <th>c3</th>\n      <td>广州</td>\n      <td>101.3</td>\n      <td>119.4</td>\n      <td>120.0</td>\n    </tr>\n    <tr>\n      <th>c4</th>\n      <td>深圳</td>\n      <td>102.0</td>\n      <td>140.9</td>\n      <td>145.5</td>\n    </tr>\n    <tr>\n      <th>c5</th>\n      <td>沈阳</td>\n      <td>100.1</td>\n      <td>101.4</td>\n      <td>101.6</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "source": [
    "d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "c1    北京\nc2    上海\nc3    广州\nc4    深圳\nc5    沈阳\nName: 城市, dtype: object"
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "source": [
    "d.loc[:,'城市']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "c1    北京\nc2    上海\nc3    广州\nc4    深圳\nc5    沈阳\nName: 城市, dtype: object"
     },
     "metadata": {},
     "execution_count": 7
    }
   ],
   "source": [
    "d.iloc[:,0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "城市       上海\n环比    101.2\n同比    127.3\n定基    127.8\nName: c2, dtype: object"
     },
     "metadata": {},
     "execution_count": 8
    }
   ],
   "source": [
    "d.loc['c2',:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "城市       上海\n环比    101.2\n同比    127.3\n定基    127.8\nName: c2, dtype: object"
     },
     "metadata": {},
     "execution_count": 9
    }
   ],
   "source": [
    "d.iloc[1,:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "127.3"
     },
     "metadata": {},
     "execution_count": 11
    }
   ],
   "source": [
    "d.iloc[1,2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}